package com.mbc.controller;


import com.mbc.pojo.MbcLoveContributions;
import com.mbc.service.LoveContributionsService;
import com.mbc.comment.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 爱心贡献控制器
 *
 * @author suimeng
 * @date 2024/04/08
 */
@RestController
@RequestMapping("/Love")
@Api(tags = "爱心贡献接口")
@CrossOrigin
public class LoveContributionsController {

    @Autowired
    private LoveContributionsService loveContributionsService;

    /**
     * 爱心贡献
     *
     * @param userId 用户 ID
     * @return {@link Result}<{@link MbcLoveContributions}>
     */
    @GetMapping("/{userId}")
    @ApiOperation("查询爱心贡献表")
    public Result<MbcLoveContributions> LoveContributions(@PathVariable String userId){
        MbcLoveContributions mbcLoveContributions = loveContributionsService.getByUserId(userId);
        return Result.success(mbcLoveContributions);
    }

    /**
     * 爱心贡献获取
     *
     * @param userId 用户 ID
     * @return {@link Result}
     */
    @PostMapping("/attendance/{userId}")
    @ApiOperation("更新爱心贡献")
    private Result<Boolean> loveContributionAcquisition(@PathVariable String userId){
       return  Result.success(loveContributionsService.updateLoveContribution(userId));
    }
}
